﻿using Gdmec.Cache;
using Gdmec.Hot;
using Gdmec.Load;
using Gdmec.Lua;
using Gdmec.UI;
using Gdmec.Timer;
using Gdmec.Audio;
using System.IO;
using Gdmec.Util;
using UnityEngine;
using DG.Tweening;
using System.Collections.Generic;

namespace Gdmec.Main
{
    public class GameMain : MonoBehaviour
    {

        public GameObject go;

        void Awake()
        {
            DontDestroyOnLoad(gameObject);
            gameObject.AddComponent<CacheManager>();
            gameObject.AddComponent<LoadManager>();
            gameObject.AddComponent<LuaManager>();
            gameObject.AddComponent<UIManager>();
            gameObject.AddComponent<HotfixManager>();
            gameObject.AddComponent<TimeManager>();
            gameObject.AddComponent<AudioManager>();
            LoadManager.SetCache(CacheManager.Instance);
            UIManager.SetUIRoot(transform.Find("UI/Canvas"));
        }

        [System.Obsolete]
        void Start()
        {
            //HotfixManager.Hot(() =>
            //{
            //    LuaManager.DoLua("Main.lua");
            //});
            System.Action func = this.Awake;

            func();
            func.Invoke();

            LuaManager.DoLua("Main.lua");
        }

    }

}